from appium import webdriver

from app.base_page.base_page import BasePage
from app.page.main import Main


class APP(BasePage):
    _appPackage = ""
    _appActivity = ""

    # 启动APP
    def start(self):
        caps = dict()
        caps["platformName"] = "Android"
        caps["appPackage"] = self._appPackage
        caps["appActivity"] = self._appActivity
        caps["automationName"] = "UiAutomator2"
        caps["noReset"] = True

        self._driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub",caps)
        self._driver.implicitly_wait(3)

        # 链式调用
        return self

    # 进入APP主页
    def main(self) -> Main:
        return Main(self._driver)
